package com.hht.toolanduilibs.wb

import android.content.ComponentName
import android.content.Context
import androidx.core.content.FileProvider
import com.hht.toolanduilibs.ConfigurationBean
import com.hht.toolanduilibs.startActivityExt
import com.hht.toolanduilibs.startServiceExt
import java.io.File


/**
 * Author:chen'hu
 * Time:2024/9/10 15:19
 * Description:This is LgWhiteBoard
 */
class LgWhiteBoard(
    configurationBean: ConfigurationBean,
    private val mContext: Context,
) : WhiteBoardImp(configurationBean) {

    override fun sendPicturesToWhiteBoard(file: File?): Boolean {
        return mContext.startActivityExt {
            action = whiteBoardBean.action
            file?.let {
                val uri = FileProvider.getUriForFile(mContext,
                    "com.xbh.whiteboard.fileProvider",
                    it)
                setDataAndType(uri, "image/*")
            }
        }
    }

    override fun openWhiteBoard(): Boolean {
        return mContext.startActivityExt {
            component = ComponentName(whiteBoardBean.pkgName, whiteBoardBean.className)
        }
    }

    override fun openAnnotation(): Boolean {
        //TODO 如果不是系统apk的话，必须在清单文件中加上此<uses-permission android:name="oem.permission.SENDMAIL" />权限
        return mContext.startServiceExt {
            component = ComponentName(annotationBean.pkgName, annotationBean.className)
        }
    }
}